#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int mod=998244353,inf=0x3f3f3f3f3f3f3f3f;
int k,m,n;
string s,t;
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("copy.in","r",stdin);
	freopen("copy.out","w",stdout);
	cin >> k >> m >> s >> n;
	s=" "+s;
	while(n--)
	{
		int l,r,x;
		cin >> l >> r >> x;
		l++;
		t=" ";
		for ( int i = 1 ; i <= x ; i++ )t+=s[i];
		for ( int i = l ; i <= r ; i++ )t+=s[i];
		for ( int i = x+1 ; i < s.size() ; i++ )t+=s[i];
		s="";
		for ( int i = 0 ; i < min((int)t.size(),m+1) ; i++ )s+=t[i];
	}
	for ( int i = 1 ; i <= k ; i++ )cout << s[i];
	return 0;
}//40


